package com.bw.house.controller;

import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;
import com.bw.house.entity.HouseCommunityEntity;
import com.bw.house.service.HouseCommunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


/**
 * 
 *
 * @author Hao_YunKai
 * @email 2745578447@qq.com
 * @date 2022-03-23 15:57:22
 */
@RestController
@RequestMapping("house/house-community")
public class HouseCommunityController {
    @Autowired
    private HouseCommunityService houseCommunityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseCommunityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		HouseCommunityEntity houseCommunity = houseCommunityService.getById(id);

        return R.ok().put("houseCommunity", houseCommunity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HouseCommunityEntity houseCommunity){
		houseCommunityService.save(houseCommunity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HouseCommunityEntity houseCommunity){
		houseCommunityService.updateById(houseCommunity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		houseCommunityService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
}
